package br.com.caelum.vraptor.util;

import javax.inject.Inject;

import br.com.caelum.vraptor.AroundCall;
import br.com.caelum.vraptor.Intercepts;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.anotations.Administracao;
import br.com.caelum.vraptor.componentes.AdministradorOn;
import br.com.caelum.vraptor.controller.AdministracaoController;
import br.com.caelum.vraptor.controller.CarteirasController;
import br.com.caelum.vraptor.interceptor.AcceptsWithAnnotations;
import br.com.caelum.vraptor.interceptor.SimpleInterceptorStack;

@Intercepts
@AcceptsWithAnnotations(Administracao.class)
public class AdmInterceptor {
	
	@Inject
	private AdministradorOn administradorOn;
	@Inject
	private Result result;
	
	@AroundCall
	public void intercept(SimpleInterceptorStack stack){
		if(administradorOn.islogado()){stack.next();System.out.println("Adm, passou");}
		else{
			stack.next();
			//result.redirectTo(AdministracaoController.class).login();
		}
	}

}
